<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
		<link rel="stylesheet" href="/wk3un4/houtai/lib/layui/css/layui.css" />
	</head>

	<body>
		<form class="layui-form" action=""  method="post">
			
			<!--公司介绍-->
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">公司介绍</label>
				<div class="layui-input-block" style="height: 120px;">
					<textarea name="homeIntro" id="homeIntro" lay-verify="content" placeholder="请输入内容" class="layui-textarea">
					${h.homeIntro }
					</textarea>
				</div>
			</div>
			<!--详细介绍-->
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">详细介绍</label>
				<div class="layui-input-block" style="height: 120px;">
					<textarea name="info" id="info" lay-verify="contentx" placeholder="请输入内容" class="layui-textarea">
					${h.info }</textarea>
				</div>
			</div>
			<!--企业文化-->
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">企业文化</label>
				<div class="layui-input-block" style="height: 120px;">
					<textarea name="culture" id="culture" lay-verify="contentxx" placeholder="请输入内容" class="layui-textarea">
					${h.culture }</textarea>
				</div>
			</div>
			<!--招商电话-->
			<div class="layui-form-item">
				<label class="layui-form-label">招商电话</label>
				<div class="layui-input-block">
					<input type="text" name="zsTel" id="zsTel" value="${h.zsTel }" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
				</div>
			</div>
			<!--联系电话-->
			<div class="layui-form-item">
				<label class="layui-form-label">联系电话</label>
				<div class="layui-input-block">
					<input type="text" name="lxTel" id="lxTel" value="${h.lxTel }" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
				</div>
			</div>
			<!--邮箱-->
			<div class="layui-form-item">
				<label class="layui-form-label">邮箱</label>
				<div class="layui-input-block">
					<input type="text" name="email" id="email" value="${h.email }" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
				</div>
			</div>
			<!--公司地址-->
			<div class="layui-form-item">
				<label class="layui-form-label">公司地址</label>
				<div class="layui-input-block">
					<input type="text" name="address" id="address" value="${h.address }" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	    <script type="text/javascript" src="/wk3un4/houtai/lib/layui/layui.js" ></script>

		<script>
			//Demo
			layui.use(['form','layedit'], function() {
				var form = layui.form;
				 var layedit = layui.layedit;
				 var $ = layui.jquery; //引入jquery
				 var index=layedit.build('homeIntro');//建立编辑器
				 //提交之前同步到富文本编辑器的值到文本域
				   form.verify({
					  content:function(value){
						  return layedit.sync(index);
					  }
				  });
				  var indexx=layedit.build('info');//建立编辑器
				  form.verify({
					  contentx:function(value){
						  return layedit.sync(indexx);
					  }
				  });
				  var indexxx=layedit.build('culture');//建立编辑器
				  form.verify({
					  contentxx:function(value){
						  return layedit.sync(indexxx);
					  }
				  }); 
				//监听提交
					form.on('submit(formDemo)', function(data) {
						var d = data.field; //表单中的数据，定义一个对象来接收
						d.method = "update"; // 我的密匙、大家用你们自己的
						//通过ajax向数据库提交数据了
						console.log(d); //提交之前的一个数据验证、通过打印的方式先手动的去判断一下这个数据
						var url = '/wk3un4/HouHomeInfoServlet';
						//确保数据没有问题就进行ajax提交了
						$.post(url, d,
							function(data) {
								if(data.count>0){
									console.log('修改成功');
								}
							}, "json");
						return false;
					});
			});
		</script>
	</body>

</html>